from socialbar.models import Logs
from socialbar.constants import PAGES
from django.contrib.auth.models import User
import logging
from time import gmtime, strftime

def logAction(request, action, description):
  log = Logs()
  log.username = request.user
  log.ipAdress = request.META.get('HTTP_X_FORWARDED_FOR', '') or request.META.get('REMOTE_ADDR')
  log.page = request.path
  log.action = action
  log.date = strftime("%Y-%m-%d %H:%M:%S", gmtime())  
  log.description = description
  log.save()

